
using System;
using System.Collections;
using System.Collections.Generic;

namespace LightScribe
{
	public class DiscPrinters : IEnumerable<DiscPrinter>
	{	
		public static DiscPrinters Printers = new DiscPrinters();
		
		private DiscPrinters()
		{
		}
		
		public IEnumerator<DiscPrinter> GetEnumerator()
		{
			IntPtr manager;
			IntPtr printers;
			Interop.DiscPrintMgr_Create(out manager);
			Interop.DiscPrintMgr_EnumDiscPrinters(manager, out printers);
			uint count;
			Interop.EnumDiscPrinters_Count(printers, out count);
			for(uint i = 0; i < count; i++)
			{
				IntPtr printer;
				Interop.EnumDiscPrinters_Item(printers, i, out printer);
				yield return new DiscPrinter(printer);
			}		
			Interop.EnumDiscPrinters_Destroy(ref printers);
			Interop.DiscPrintMgr_Destroy(ref manager);
			yield break;
		}
		
		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}
	}
}
